<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #parent{
            width: 300px;
            height: 300px;
            border: solid 0px orangered;
            margin: 0 auto;
            position: relative;/*父元素先设置相对定位，否则子元素将以浏览器为参照物*/
            box-shadow: 5px 5px 10px;
            
        }
        #parent>#child{
            width: 300px;
            height: 50px;
            background-color: rgba(0,0,255,0.2);
            position: absolute; /*子元素再设置绝对定位*/
            bottom: 0;
            left: 0;
            right: 0;
            text-align: center;
            color: #fff;
        }
    </style>
</head>
<body>
    <div id="parent">
        <img width="100%" height="100%" src="../img/boy.png" alt="">
        <div id="child"><p>这是一个帅哥</p></div>
    </div>
</body>
</html>